
import {applyMiddleware,legacy_createStore} from 'redux'
import logger from 'redux-logger'
import thunk from 'redux-thunk'

import {ALLDATALIST,ALLCTTON,GETLISTDATA,CHILDATA,FILTERSHOU} from '../types/index.d'

const initialState = {
  list:[],
  childata:[],
  filt:[]
}

const torouter =  (state:ALLDATALIST = initialState, { type, payload }:ALLCTTON) => {
  switch (type) {

  case GETLISTDATA:
      state.list = payload
      state.childata=payload[0].children
      
      
    return { ...state}

  case CHILDATA:
      // state.childata=state.list[payload].children
       
    return { ...state}


  case FILTERSHOU:
    const newfilt = [...state.filt]
    newfilt.filter((item)=>{
      item.user ? includes(payload)
    })
    return {...state}






  default:
    return state
  }
}

const store = legacy_createStore(torouter,applyMiddleware(logger,thunk))

export default store
function includes(payload: import("../types/index.d").CHILDRENDATALIST[]) {
  throw new Error('Function not implemented.')
}

